<template>
	<view>
		<view class="title">
			{{ info.delivery_name }}:{{ info.delivery_id }}
		</view>
		<uni-steps :options="list" direction="column" :active="active"></uni-steps>
	</view>
</template>

<script>
	import uniSteps from '@/components/uni-steps/uni-steps.vue'
	import {
		searchKd
	} from '@/api/user'
	export default {
		components: {uniSteps},
		data() {
			return {
				info: {
					delivery_name: '',
					delivery_id: ''
				},
				list: []
			}
		},
		computed:{
			active: function(){
				return this.info.result.length == 0 ? 0 : this.info.result.length-1
			}
		},
		methods: {
			searchInfo(id){
				searchKd(id).then(res => {
					console.log(res)
					if(res.status == 200){
						this.info = res.data
						let result = res.data.result
						let arr = []
						for(let i=0;i<result.length;i++){
							let obj = {}
							obj.desc = result[i].time
							obj.title = result[i].status
							arr.push(obj)
						}
						this.list = arr
					}else{
						uni.showToast({
							title: '获取失败'
						})
					}
				})
			}
		},
		onLoad(options) {
			let id = options.id
			if(id == undefined){
				uni.showToast({
					title: '参数错误'
				})
			}else{
				this.searchInfo(id)
			}
		}
	}
</script>

<style>
	.title{
		padding: 20rpx 30rpx;
	}
</style>
